package com.lzs.adx.web.modules.adx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzs.adx.commmon.service.impl.CrudServiceImpl;
import com.lzs.adx.web.modules.adx.dao.ResultTypeDao;
import com.lzs.adx.web.modules.adx.dto.ResultTypeDTO;
import com.lzs.adx.web.modules.adx.entity.ResultTypeEntity;
import com.lzs.adx.web.modules.adx.service.ResultTypeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @author wangzhijun 825400558@qq.com
 * @since 1.0.0 2024-07-15
 */
@Service
public class ResultTypeServiceImpl extends CrudServiceImpl<ResultTypeDao, ResultTypeEntity, ResultTypeDTO> implements ResultTypeService {

    @Override
    public QueryWrapper<ResultTypeEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<ResultTypeEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public ResultTypeEntity get(String productChannel, String type) {
        LambdaQueryWrapper<ResultTypeEntity> lambdaQueryWrapper=new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(ResultTypeEntity::getProductChannle,productChannel);
        lambdaQueryWrapper.eq(ResultTypeEntity::getType,type);
        List<ResultTypeEntity> resultTypeEntities = this.baseDao.selectList(lambdaQueryWrapper);
        return resultTypeEntities.get(0);
    }
}